// https://www.luogu.com.cn/problem/P1427

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int arr[105];
    int t = 1, cnt=0;
    while (true) {
        scanf("%d", &t);
        if (t == 0) {
            break;
        }
        arr[cnt] = t;
        cnt++;
    }

    for (int i = cnt-1; i >= 0; i--) {
        printf("%d ", arr[i]);
    }

    return 0;
}